import request from '@/utils/request'
//  审理操作的API接口
const business_Approve_Api = {
  startBusinessProced: '/businessapprove/startBusinessProced',
  getWeekdayDeadline: '/businessapprove/weekdayDeadline',
  previewDecisionDoc: '/businessapprove/previewDecisionDoc',
  previewApproveDoc: '/businessapprove/previewApproveDoc',
  previewDocByDocName: '/businessapprove/previewDocByDocName',
  savePreviewDocByMaterial: '/businessapprove/savePreviewDocByMaterial',
  updatePreviewDocByMaterial: '/businessapprove/updatePreviewDocByMaterial',
  initPreviewDocParam: '/businessapprove/initPreviewDocParam',
  savePreviewDocPdfByDocName: '/businessapprove/savePreviewDocPdfByDocName',
  changeDecisionType: '/businessapprove/changeDecisionType'
}
/**
 * 审理环节-启动一个业务子流程
 * @param {*} parameter
 * @param {*} body
 * @returns
 */
export function startBusinessProced (parameter, body) {
  return request({
    url: business_Approve_Api.startBusinessProced,
    method: 'post',
    params: parameter,
    data: body
  })
}

/**
 * 获取上限工作日时间
 */
export function getWeekdayDeadline (parameter) {
  return request({
    url: business_Approve_Api.getWeekdayDeadline,
    method: 'post',
    params: parameter
  })
}

/**
 * 在线预览生成的doc文档
 * @param {} parameter
 * @param {*} body
 * @returns
 */
export function previewDecisionDoc (parameter, body) {
  return request({
    url: business_Approve_Api.previewDecisionDoc,
    method: 'post',
    params: parameter,
    data: body,
    responseType: 'blob'
  })
}

/**
 * 在线预览生成的doc文档
 * @param {} parameter
 * @param {*} body
 * @returns
 */
 export function previewApproveDoc (applyid, modelKey, body) {
  return request({
    url: business_Approve_Api.previewApproveDoc,
    method: 'post',
    params: { applyid, modelKey },
    data: body
  })
}

/**
 * 通过文件名匹配文件生成文件流返回预览
 * @param {} parameter
 * @param {*} body
 * @returns
 */
export function previewDocByDocName (applyid, materilaType, body) {
  return request({
    url: business_Approve_Api.previewDocByDocName,
    method: 'post',
    params: { applyid, materilaType },
    data: body,
    responseType: 'blob'
  })
}

/**
 * 通过文件名匹配文件生成文件流转换为pdf返回保存
 * @param {} parameter
 * @param {*} body
 * @returns
 */
export function savePreviewDocPdfByDocName (applyid, materilaType, body) {
  return request({
    url: business_Approve_Api.savePreviewDocPdfByDocName,
    method: 'post',
    params: { applyid, materilaType },
    data: body,
    responseType: 'blob'
  })
}

/**
 * 预览文件保存到mino并且记录到数据库中
 * @param {} parameter
 * @param {*} body
 * @returns
 */
export function savePreviewDocByMaterial (applyid, materilaType, busiType, userId, userName, body) {
  return request({
    url: business_Approve_Api.savePreviewDocByMaterial,
    method: 'post',
    params: { applyid, materilaType, busiType, userId, userName },
    data: body
  })
}

/**
 * 预览文件更新对应记录
 * @param {*} optionid
 * @param {*} userId
 * @param {*} userName
 * @param {*} body
 * @returns
 */
export function updatePreviewDocByMaterial (optionid, userId, userName, body) {
  return request({
    url: business_Approve_Api.updatePreviewDocByMaterial,
    method: 'post',
    params: { optionid, userId, userName },
    data: body
  })
}

/**
 * 初始化阶段的材料表单字段查询
 * @param {*} applyid
 * @param {*} materilaType
 * @returns
 */
export function initPreviewDocParam (applyid, materilaType) {
  return request({
    url: business_Approve_Api.initPreviewDocParam,
    method: 'post',
    params: { applyid, materilaType }
  })
}

/**
 * 改变决定类型
 * @param {*} f_applyid
 * @param {*} applyid
 * @param {*} decisiontype
 * @param {*} decisiontypeid
 * @param {*} decisiontypename
 * @returns
 */
export function changeDecisionType (f_applyid, applyid, decisiontype, decisiontypeid, decisiontypename) {
  return request({
    url: business_Approve_Api.changeDecisionType,
    method: 'post',
    params: { f_applyid, applyid, decisiontype, decisiontypeid, decisiontypename }
  })
}
